package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.MeterBox;
import com.lrkj.payfee.service.IMeterBoxService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 仪表箱Controller
 *
 * @author yajun_ren
 * @date 2021-07-27
 */
@RestController
@RequestMapping("/payfee/box")
public class MeterBoxController extends BaseController
{
    @Autowired
    private IMeterBoxService meterBoxService;

    /**
     * 查询仪表箱列表
     */
    @ApiOperation(value = "查询仪表箱列表", notes = "查询仪表箱列表")
    @GetMapping("/list")
    public TableDataInfo list(MeterBox meterBox)
    {
        startPage();
        List<MeterBox> list = meterBoxService.selectMeterBoxList(meterBox);
        return getDataTable(list);
    }

    /**
     * 导出仪表箱列表
     */
	@ApiOperation(value = "导出仪表箱列表", notes = "导出仪表箱列表")
    @PreAuthorize("@ss.hasPermi('payfee:box:export')")
    @Log(title = "仪表箱", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MeterBox meterBox)
    {
        List<MeterBox> list = meterBoxService.selectMeterBoxList(meterBox);
        ExcelUtil<MeterBox> util = new ExcelUtil<MeterBox>(MeterBox.class);
        return util.exportExcel(list, "仪表箱数据");
    }

    /**
     * 获取仪表箱详细信息
     */
	@ApiOperation(value = "获取仪表箱详细信息", notes = "获取仪表箱详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:box:query')")
    @GetMapping(value = "/{boxId}")
    public AjaxResult getInfo(@PathVariable("boxId") String boxId)
    {
        return AjaxResult.success(meterBoxService.selectMeterBoxById(boxId));
    }

    /**
     * 新增仪表箱
     */
	  @ApiOperation(value = "新增仪表箱", notes = "新增仪表箱")
    @PreAuthorize("@ss.hasPermi('payfee:box:add')")
    @Log(title = "仪表箱", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MeterBox meterBox)
    {
        return toAjax(meterBoxService.insertMeterBox(meterBox));
    }

    /**
     * 修改仪表箱
     */
	 @ApiOperation(value = "修改仪表箱", notes = "修改仪表箱")
    @PreAuthorize("@ss.hasPermi('payfee:box:edit')")
    @Log(title = "仪表箱", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MeterBox meterBox)
    {
        return toAjax(meterBoxService.updateMeterBox(meterBox));
    }

    /**
     * 删除仪表箱
     */
	 @ApiOperation(value = "删除仪表箱", notes = "删除仪表箱")
    @PreAuthorize("@ss.hasPermi('payfee:box:remove')")
    @Log(title = "仪表箱", businessType = BusinessType.DELETE)
	@DeleteMapping("/{boxIds}")
    public AjaxResult remove(@PathVariable String[] boxIds)
    {
        return toAjax(meterBoxService.deleteMeterBoxByIds(boxIds));
    }
}
